package com.案例.文件中元素写到集合;

import lombok.SneakyThrows;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;

public class Demo {
    @SneakyThrows
    public static void main(String[] args) {
        BufferedReader bufferedReader = new BufferedReader(new FileReader("hello.txt"));
        ArrayList<String> strings = new ArrayList<>();

        String ch;
        while ((ch=bufferedReader.readLine())!=null){
            strings.add(ch);

        }

        for (String st : strings) {

            System.out.println(st);
        }

    }
}
